package com.company.OfferGuide;

public class 数值的整数次方 {

    public static void main(String[] args) {
        System.out.println(myPow(2, -2147483648));
        System.out.println(Math.pow(2, -2147483648));
    }

    public static double myPow(double x, int n) {
        if (n == 0) return 1.0;
        if (n == -1) return 1/x;
        if (n == 1) return x;
        int mid = n / 2;
        double res = myPow(x,mid);
        double mod = myPow(x, n % 2);

        return res * res * mod;
    }

}
